package com.wc.alorithm_luogu._前缀和与差分.语文成绩;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/1/8 20:12
 * @description
 * https://www.luogu.com.cn/problem/P2367
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 5000010;
    static int[] a = new int[N], d = new int[N];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) d[i] = a[i] - a[i - 1];
        int l, r, x;
        while (m-- > 0) {
            l = sc.nextInt();
            r = sc.nextInt();
            x = sc.nextInt();
            d[l] += x;
            d[r + 1] -= x;
        }
        int minv = 5000000 * 100 + 100;
        for (int i = 1; i <= n; i++) {
            d[i] += d[i - 1];
            minv = Math.min(minv, d[i]);
        }

        out.println(minv);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
}

